# makefile for mana (compiler)
# Copyright (c) 2003 Shun Moriya <shun126@users.sourceforge.jp>
#
# The MIT License
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
# THE USE OR OTHER DEALINGS IN THE SOFTWARE.

TARGET	= mana
CC	= gcc
CFLAGS	= -m32 -c -O3 -Wall -D NDEBUG --input-charset=utf-8
LK	= gcc
LFLAGS	= -m32
YACC	= bison
YFLAGS	= -d -k
LEX	= flex
LXFLAGS	= -8 -F

CP      = cp -f
RM	= rm -f

HEADERS	= mana_code.h mana_data.h mana_datalink_generator.h mana_jump.h mana_linker.h mana_main.h mana_node.h mana_pool.h mana_register.h mana_symbol.h mana_type.h ../library/mana_datalink.h ../library/mana_hash.h ../library/mana_malloc.h ../library/mana_info.h
SOURCES	= mana_code.c mana_data.c mana_datalink_generator.c mana_jump.c mana_linker.c mana_main.c mana_node.c mana_pool.c mana_register.c mana_symbol.c mana_type.c ../library/mana_datalink.c ../library/mana_hash.c ../library/mana_malloc.c ../library/mana_info.c mana_parser.y mana_lexer.l
OBJECTS	= mana_code.o mana_data.o mana_datalink_generator.o mana_jump.o mana_linker.o mana_main.o mana_node.o mana_pool.o mana_register.o mana_symbol.o mana_type.o ../library/mana_datalink.o ../library/mana_hash.o ../library/mana_malloc.o ../library/mana_info.o mana_parser.o mana_lexer.o

SECOUND	= mana_parser.c mana_parser.h mana_lexer.c

.SUFFIXES: .y .l .c .o

.SECOUNDLY: $(SECOUND)

$(TARGET): $(HEADERS) $(SOURCES) $(OBJECTS)
	$(LK) $(LFLAGS) -o $(TARGET) $(OBJECTS)

.l.c:
	$(LEX) $(LXFLAGS) -o$@ $<

.y.c:
	$(YACC) $(YFLAGS) -o $@ $<

.c.o: $(HEADERS)
	$(CC) $(CFLAGS) -o $@ $<

run:
	./$(TARGET) --debug ../script/test.mn

clean:
	$(RM) $(TARGET) $(OBJECTS) $(SECOUND)

depend:
	makedepend -Y -- $(CFLAGS) -- $(SOURCES)

# DO NOT DELETE

mana_code.o: mana_code.h mana_main.h ../library/mana_datalink.h
mana_code.o: ../library/mana_hash.h ../library/mana_info.h
mana_code.o: ../library/mana_malloc.h mana_pool.h
mana_data.o: ../library/mana_info.h ../library/mana_malloc.h mana_data.h
mana_datalink_generator.o: mana_main.h ../library/mana_datalink.h
mana_datalink_generator.o: ../library/mana_hash.h ../library/mana_info.h
mana_datalink_generator.o: ../library/mana_malloc.h mana_pool.h
mana_datalink_generator.o: mana_datalink_generator.h
mana_jump.o: mana_main.h ../library/mana_datalink.h ../library/mana_hash.h
mana_jump.o: ../library/mana_info.h ../library/mana_malloc.h mana_pool.h
mana_jump.o: mana_code.h mana_jump.h mana_node.h mana_symbol.h mana_type.h
mana_jump.o: mana_linker.h
mana_linker.o: mana_code.h mana_data.h mana_linker.h mana_node.h
mana_linker.o: mana_symbol.h mana_type.h mana_main.h
mana_linker.o: ../library/mana_datalink.h ../library/mana_hash.h
mana_linker.o: ../library/mana_info.h ../library/mana_malloc.h mana_pool.h
mana_main.o: mana_main.h ../library/mana_datalink.h ../library/mana_hash.h
mana_main.o: ../library/mana_info.h ../library/mana_malloc.h mana_pool.h
mana_main.o: mana_code.h mana_data.h mana_datalink_generator.h mana_jump.h
mana_main.o: mana_node.h mana_symbol.h mana_type.h mana_version.h
mana_node.o: mana_data.h mana_datalink_generator.h mana_main.h
mana_node.o: ../library/mana_datalink.h ../library/mana_hash.h
mana_node.o: ../library/mana_info.h ../library/mana_malloc.h mana_pool.h
mana_node.o: mana_node.h mana_symbol.h mana_type.h
mana_pool.o: ../library/mana_malloc.h mana_pool.h
mana_symbol.o: mana_code.h mana_data.h mana_linker.h mana_node.h
mana_symbol.o: mana_symbol.h mana_type.h mana_main.h
mana_symbol.o: ../library/mana_datalink.h ../library/mana_hash.h
mana_symbol.o: ../library/mana_info.h ../library/mana_malloc.h mana_pool.h
mana_type.o: mana_main.h ../library/mana_datalink.h ../library/mana_hash.h
mana_type.o: ../library/mana_info.h ../library/mana_malloc.h mana_pool.h
mana_type.o: mana_symbol.h mana_type.h
../library/mana_datalink.o: ../library/mana_datalink.h
../library/mana_datalink.o: ../library/mana_malloc.h
../library/mana_hash.o: ../library/mana_hash.h ../library/mana_malloc.h
../library/mana_malloc.o: ../library/mana_malloc.h
../library/mana_info.o: ../library/mana_malloc.h ../library/mana_info.h
mana_parser.o: mana_code.h mana_data.h mana_jump.h mana_node.h mana_symbol.h
mana_parser.o: mana_type.h mana_linker.h mana_main.h
mana_parser.o: ../library/mana_datalink.h ../library/mana_hash.h
mana_parser.o: ../library/mana_info.h ../library/mana_malloc.h mana_pool.h
mana_lexer.o: mana_main.h ../library/mana_datalink.h ../library/mana_hash.h
mana_lexer.o: ../library/mana_info.h ../library/mana_malloc.h mana_pool.h
mana_lexer.o: mana_node.h mana_symbol.h mana_type.h mana_parser.h
